{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='id' id='id' value="{$info.id}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">红娘id：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="matchmaker_id"   value="{$info.matchmaker_id}"   name="matchmaker_id" class="form-control" placeholder="请输入红娘id"  >
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">文字：</label>
						<div class="col-sm-9">
							<input type="number" autocomplete="off" id="content" value="{$info.content}"    name="content" class="form-control" placeholder="请输入文字"  >
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">照片：</label>
						<div class="col-sm-6">
							<div class="images pic_list">
								<li id="images_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none images_process"></span>
						</div>
					</div>

					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['status'])){ $info['status'] = '0'; }; ?>
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="通过">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="待审核">
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
uploader('images_upload', 'images', 'image', true, '{$info.photos}', '{:getUploadServerUrl()}');
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		status: {
			validators: {
				notEmpty: {
					message: '状态不能为空'
	 			},
	 		}
	 	},
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('content').set('matchmaker_id').set('id');
};



CodeInfoDlg.update = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	var status = $("input[name = 'status']:checked").val();
	var images = [];
	$(".images li").each(function () {
		if ($(this).find('img').attr('src')) {
			images.push($(this).find('img').attr('src'));
		}
	});

	 var ajax = new $ax(Feng.ctxPath + "/ZhMatchmakerAddinfo/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('status',status);
	ajax.set('photos',images);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
